home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / AstroBubble.dxr / 00021_Game Scripts.ls < prev    next >
Encoding:
Text File  |  2002-01-25  |  15.0 KB  |  402 lines

  1. global playerSO, rescueSO, fallingSO, chainSO, playerLocData, rescueData, fallingData, floorHeight, maxRescueThings, maxFallingThings, maxChainLinks, chainLinkDist, inputString, mouseinput, playerPower, updatepowerDisplay, particleSO, maxParticles, particle_RefList, particleData, playerViewPoint
  2.  
  3. on initializeConstants
  4.   playerSO = 10
  5.   rescueSO = 12
  6.   fallingSO = 22
  7.   chainSO = 30
  8.   floorHeight = 420
  9.   maxRescueThings = 1
  10.   maxFallingThings = 8
  11.   maxChainLinks = 40
  12.   chainLinkDist = 22
  13.   particleSO = 70
  14.   maxParticles = 35
  15.   playerViewPoint = point(0, 0)
  16. end
  17.  
  18. on initializeplayer
  19.   playerLocData = [0, 290, 0, 0, 0, 0]
  20.   puppetSprite(playerSO, 1)
  21.   set the member of sprite playerSO to "Bow 1"
  22.   set the ink of sprite playerSO to 32
  23.   set the backColor of sprite playerSO to 0
  24.   set the loc of sprite playerSO to point(-50, -50)
  25.   puppetSprite(playerSO + 1, 1)
  26.   set the member of sprite (playerSO + 1) to "Bubble_Small 1"
  27.   set the ink of sprite (playerSO + 1) to 32
  28.   set the loc of sprite (playerSO + 1) to point(-50, -50)
  29.   puppetSprite(playerSO + 2, 1)
  30.   set the member of sprite (playerSO + 2) to "Plunger Empty"
  31.   set the ink of sprite (playerSO + 2) to 36
  32.   set the loc of sprite (playerSO + 2) to point(-50, -50)
  33. end
  34.  
  35. on initializeRescueThings
  36.   rescueData = []
  37.   repeat with wRescue = 1 to maxRescueThings
  38.     add(rescueData, [0, point(0, 0), point(0, 0), 0, 0, 0, 0, 0])
  39.     wSprite = rescueSO + wRescue
  40.     puppetSprite(wSprite, 1)
  41.     set the member of sprite wSprite to "Plunger Empty"
  42.     set the ink of sprite wSprite to 32
  43.     set the loc of sprite wSprite to point(-50, -50)
  44.   end repeat
  45. end
  46.  
  47. on initializeFallingThings
  48.   fallingData = []
  49.   repeat with wFalling = 1 to maxFallingThings
  50.     add(fallingData, [0, point(0, 0)])
  51.     wSprite = fallingSO + wFalling
  52.     puppetSprite(wSprite, 1)
  53.     set the member of sprite wSprite to "Falling Object"
  54.     set the ink of sprite wSprite to 32
  55.     set the loc of sprite wSprite to point(-50, -50)
  56.   end repeat
  57. end
  58.  
  59. on initializeChainLinks
  60.   global maxChainLinks, chainSO
  61.   repeat with wLink = 1 to maxChainLinks
  62.     wSprite = chainSO + wLink
  63.     puppetSprite(wSprite, 1)
  64.     set the member of sprite wSprite to "Chain 1"
  65.     set the ink of sprite wSprite to 36
  66.     set the loc of sprite wSprite to point(-50, -50)
  67.   end repeat
  68. end
  69.  
  70. on drawChain
  71.   global maxChainLinks, chainSO, floorHeight, chainLinkDist, animateoffset
  72.   animateoffset = animateoffset + 1
  73.   if rescueData[1][1] = 1 then
  74.     locY = integer(cos(rescueData[1][6] * PI / 180) * -30)
  75.     locX = integer(sin(rescueData[1][6] * PI / 180) * 30)
  76.     startLoc = rescueData[1][2] - point(locX, locY)
  77.     TargetLoc = point(playerLocData[2], floorHeight)
  78.   else
  79.     startLoc = point(playerLocData[2], floorHeight)
  80.     TargetLoc = point(playerLocData[2], floorHeight)
  81.   end if
  82.   repeat with wLink = 1 to maxChainLinks
  83.     wSprite = chainSO + wLink
  84.     moveAim = findAngle(startLoc, TargetLoc)
  85.     moveDist = findDistance(startLoc, TargetLoc)
  86.     if moveDist <= chainLinkDist then
  87.       startLoc = TargetLoc
  88.     else
  89.       locY = integer(cos(moveAim * PI / 180) * -chainLinkDist)
  90.       locX = integer(sin(moveAim * PI / 180) * (chainLinkDist * 0.59999999999999998))
  91.       newAim = findAngle(point(0, 0), point(locX, locY))
  92.       locY2 = integer(cos(newAim * PI / 180) * -chainLinkDist)
  93.       locX2 = integer(sin(newAim * PI / 180) * chainLinkDist)
  94.       startLoc = startLoc + point(locX2, locY2)
  95.     end if
  96.     mNum = ((animateoffset + wLink) mod 12) + 1
  97.     set the member of sprite wSprite to "Chain " & string(mNum)
  98.     sprite(wSprite).rotation = findAngle(point(0, 0), point(locX, locY))
  99.     set the loc of sprite wSprite to startLoc
  100.   end repeat
  101. end
  102.  
  103. on addFallingThing spawnloc
  104.   global gameLevel, gameProgress
  105.   validSlot = 0
  106.   repeat with wScan = 1 to count(fallingData)
  107.     if (validSlot = 0) and (fallingData[wScan][1] = 0) then
  108.       validSlot = wScan
  109.     end if
  110.   end repeat
  111.   gameProgress = gameProgress + 1
  112.   if gameProgress > 20 then
  113.     gameProgress = 0
  114.     gameLevel = gameLevel + 1
  115.   end if
  116.   if validSlot <> 0 then
  117.     btList = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3]
  118.     rValue = btList[random(count(btList))]
  119.     fSpeed = 0.5 + (random(gameLevel + 2) * 0.25)
  120.     fallingData[validSlot] = [1, spawnloc, 1, rValue, fSpeed]
  121.   end if
  122. end
  123.  
  124. on moveFallingThings
  125.   global updatepowerDisplay, playerScore
  126.   repeat with wFalling = 1 to count(fallingData)
  127.     wSprite = fallingSO + wFalling
  128.     if fallingData[wFalling][1] = 1 then
  129.       fallingData[wFalling][2] = fallingData[wFalling][2] + point(0, fallingData[wFalling][5])
  130.       if fallingData[wFalling][2][2] > floorHeight then
  131.         repeat with wVector = 1 to 15
  132.           rAim = (wVector * 360 / 15) + random(10)
  133.           moveDist = 200
  134.           driftDist = random(25)
  135.           locY1 = integer(cos(rAim * PI / 180) * -moveDist)
  136.           locX1 = integer(sin(rAim * PI / 180) * moveDist)
  137.           locY2 = integer(cos(rAim * PI / 180) * -driftDist)
  138.           locX2 = integer(sin(rAim * PI / 180) * driftDist)
  139.           addparticle(2, (fallingData[wFalling][2] * 10) + point(locX1, locY1), point(locX2, locY2))
  140.         end repeat
  141.         playerPower = playerPower - 1
  142.         if playerPower < 0 then
  143.           playerPower = 0
  144.         end if
  145.         updatepowerDisplay = 1
  146.         fallingData[wFalling][1] = 0
  147.         playerScore = integer(playerScore * 0.90000000000000002)
  148.         playSound("Burst Bubble", 1)
  149.       end if
  150.       effectType = [0, 5, 4][fallingData[wFalling][4]]
  151.       if effectType <> 0 then
  152.         addparticle(effectType, fallingData[wFalling][2] * 10, point(0, 0))
  153.       end if
  154.       set the loc of sprite wSprite to fallingData[wFalling][2]
  155.       next repeat
  156.     end if
  157.     set the loc of sprite wSprite to point(-50, -50)
  158.   end repeat
  159. end
  160.  
  161. on moveRescueThings
  162.   global playerScore, flareTypeAbsorb, messageData, speedlevel
  163.   updateScore = 0
  164.   repeat with wRescue = 1 to maxRescueThings
  165.     wSprite = rescueSO + wRescue
  166.     if rescueData[wRescue][1] = 1 then
  167.       rescueData[wRescue][5] = rescueData[wRescue][5] + 5
  168.       distancetraveled = rescueData[wRescue][1]
  169.       if rescueData[wRescue][4] = 0 then
  170.         moveSpeed = findDistance(rescueData[wRescue][2], rescueData[wRescue][3])
  171.         chunkMove = (moveSpeed * 0.07000000000000001) + 1
  172.         rescueData[wRescue][2] = rescueData[wRescue][2] - point(0, chunkMove)
  173.         if rescueData[wRescue][7] = 0 then
  174.           temination = 0
  175.           saveOb = 0
  176.           repeat with wFalling = 1 to count(fallingData)
  177.             if fallingData[wFalling][1] = 1 then
  178.               savingDist = findDistance(rescueData[wRescue][2], fallingData[wFalling][2])
  179.               if savingDist <= 20 then
  180.                 temination = 1
  181.                 saveOb = wFalling
  182.               end if
  183.             end if
  184.           end repeat
  185.           if saveOb <> 0 then
  186.             if chunkMove <= 3 then
  187.               flareTypeAbsorb = fallingData[saveOb][4]
  188.               if fallingData[saveOb][4] = 2 then
  189.                 speedlevel = speedlevel + 1
  190.                 if speedlevel > 5 then
  191.                   speedlevel = 5
  192.                   playerScore = playerScore + 40
  193.                 end if
  194.                 messageData = [1, fallingData[saveOb][2], 0]
  195.                 updatepowerDisplay = 1
  196.               else
  197.                 if fallingData[saveOb][4] = 3 then
  198.                   playerPower = playerPower + 1
  199.                   if playerPower > 10 then
  200.                     playerPower = 10
  201.                     playerScore = playerScore + 40
  202.                   end if
  203.                   messageData = [2, fallingData[saveOb][2], 0]
  204.                   updatepowerDisplay = 1
  205.                 end if
  206.               end if
  207.               rescueData[wRescue][7] = 1
  208.               fallingData[saveOb][1] = 0
  209.               playerScore = playerScore + 40
  210.               updateScore = 1
  211.             else
  212.               playerScore = integer(playerScore * 0.90000000000000002)
  213.               updatepowerDisplay = 1
  214.               repeat with wVector = 1 to 15
  215.                 rAim = (wVector * 360 / 15) + random(10)
  216.                 moveDist = 200
  217.                 driftDist = random(25)
  218.                 locY1 = integer(cos(rAim * PI / 180) * -moveDist)
  219.                 locX1 = integer(sin(rAim * PI / 180) * moveDist)
  220.                 locY2 = integer(cos(rAim * PI / 180) * -driftDist)
  221.                 locX2 = integer(sin(rAim * PI / 180) * driftDist)
  222.                 addparticle(2, (fallingData[saveOb][2] * 10) + point(locX1, locY1), point(locX2, locY2))
  223.               end repeat
  224.               playerPower = playerPower - 1
  225.               updatepowerDisplay = 1
  226.               fallingData[saveOb][1] = 0
  227.               playSound("Burst Bubble", 1)
  228.             end if
  229.           end if
  230.         end if
  231.         if rescueData[wRescue][2][2] < rescueData[wRescue][3][2] then
  232.           rescueData[wRescue][4] = 1
  233.         end if
  234.         rescueData[wRescue][6] = 0
  235.       else
  236.         moveSpeed = findDistance(rescueData[wRescue][2], rescueData[wRescue][3])
  237.         startLoc = rescueData[wRescue][2]
  238.         TargetLoc = point(playerLocData[2], floorHeight)
  239.         moveAim = findAngle(startLoc, TargetLoc)
  240.         retractSpeed = (moveSpeed * 0.05) + 35
  241.         locY = integer(cos(moveAim * PI / 180) * -(retractSpeed * 1.0))
  242.         locX = integer(sin(moveAim * PI / 180) * (retractSpeed * 0.5))
  243.         rescueData[wRescue][2] = rescueData[wRescue][2] + point(locX, locY)
  244.         rescueData[wRescue][6] = moveAim + 180
  245.         if rescueData[wRescue][2][2] > (floorHeight - 15) then
  246.           rescueData[wRescue][1] = 0
  247.         end if
  248.       end if
  249.       if rescueData[wRescue][7] = 1 then
  250.         set the member of sprite wSprite to "Plunger Full"
  251.         repeat with wSpark = 1 to 1
  252.           rAim = moveAim
  253.           rDist = random(50) + 150
  254.           locY = integer(cos(rAim * PI / 180) * -rDist)
  255.           locX = integer(sin(rAim * PI / 180) * rDist)
  256.           rAim2 = random(360)
  257.           rDist2 = random(200) + 20
  258.           locY2 = integer(cos(rAim2 * PI / 180) * -rDist2)
  259.           locX2 = integer(sin(rAim2 * PI / 180) * rDist2)
  260.           addparticle(2, (rescueData[wRescue][2] * 10) + point(locX2, locY2), point(locX, locY) / 3)
  261.         end repeat
  262.         if rescueData[wRescue][8] < 6 then
  263.           rescueData[wRescue][8] = rescueData[wRescue][8] + 0.20000000000000001
  264.           set the member of sprite wSprite to "Grab" & string(integer(rescueData[wRescue][8] + 1))
  265.         end if
  266.         if flareTypeAbsorb <> 1 then
  267.           rAim = rescueData[wRescue][6]
  268.           locY = integer(cos(rAim * PI / 180) * -20)
  269.           locX = integer(sin(rAim * PI / 180) * 20)
  270.           addparticle([0, 5, 4][flareTypeAbsorb], (rescueData[wRescue][2] + point(locX, locY)) * 10, point(0, 0))
  271.         end if
  272.       else
  273.         set the member of sprite wSprite to "Plunger Empty"
  274.       end if
  275.       sprite(wSprite).rotation = rescueData[wRescue][6]
  276.       set the loc of sprite wSprite to rescueData[wRescue][2]
  277.       next repeat
  278.     end if
  279.     set the loc of sprite wSprite to point(-50, -50)
  280.   end repeat
  281.   if updateScore = 1 then
  282.     member("score display").text = string(playerScore)
  283.   end if
  284. end
  285.  
  286. on addRescueThing spawnloc, TargetLoc
  287.   global gameLevel, gameProgress
  288.   validSlot = 0
  289.   repeat with wScan = 1 to count(rescueData)
  290.     if (rescueData[wScan][1] = 0) and (validSlot = 0) then
  291.       validSlot = wScan
  292.     end if
  293.   end repeat
  294.   if validSlot <> 0 then
  295.     if TargetLoc[2] > 300 then
  296.       TargetLoc[2] = 300
  297.     end if
  298.     playSound("Chain Retract", 2)
  299.     rescueData[validSlot] = [1, spawnloc, TargetLoc, 0, random(360), 0, 0, 0]
  300.   end if
  301. end
  302.  
  303. on moveplayer
  304.   global speedlevel
  305.   playerAccelSpeed = 2 + speedlevel
  306.   playerMaxSpeed = 5 + speedlevel
  307.   playerAction = #idle
  308.   if the mouseH > (playerLocData[2] + playerMaxSpeed) then
  309.     playerAction = #moveRight
  310.   else
  311.     if the mouseH < (playerLocData[2] - playerMaxSpeed) then
  312.       playerAction = #moveLeft
  313.     end if
  314.   end if
  315.   moveSpeed = playerLocData[2]
  316.   case playerAction of
  317.     #moveLeft:
  318.       playerLocData[3] = playerLocData[3] - playerAccelSpeed
  319.       if playerLocData[3] < (0 - playerMaxSpeed) then
  320.         playerLocData[3] = 0 - playerMaxSpeed
  321.       end if
  322.     #moveRight:
  323.       playerLocData[3] = playerLocData[3] + playerAccelSpeed
  324.       if playerLocData[3] > playerMaxSpeed then
  325.         playerLocData[3] = playerMaxSpeed
  326.       end if
  327.     otherwise:
  328.       repeat with wRep = 1 to integer(playerAccelSpeed)
  329.         if playerLocData[3] > 0 then
  330.           playerLocData[3] = playerLocData[3] - 1
  331.           next repeat
  332.         end if
  333.         if playerLocData[3] < 0 then
  334.           playerLocData[3] = playerLocData[3] + 1
  335.         end if
  336.       end repeat
  337.   end case
  338.   if (floorHeight - playerLocData[4]) <= 0 then
  339.     playerLocData[5] = 200 - ((floorHeight - playerLocData[4]) * 200 / floorHeight)
  340.     addRescueThing(point(playerLocData[2], floorHeight - 15), point(playerLocData[2], floorHeight - playerLocData[4]))
  341.     set the loc of sprite (playerSO + 1) to point(-50, -50)
  342.     playerLocData[4] = 0
  343.   else
  344.     if mouseinput = 1 then
  345.       playerLocData[5] = 200 - ((floorHeight - playerLocData[4]) * 200 / floorHeight) + 1
  346.       playerLocData[6] = 0
  347.       playerLocData[4] = playerLocData[4] + 5
  348.       TargetLoc = point(playerLocData[2], floorHeight - playerLocData[4])
  349.       addparticle(3, TargetLoc * 10, point(random(15) - 8, random(15) - 8))
  350.       bubblepoint = point(TargetLoc[1], (TargetLoc[2] mod 30) + 30)
  351.       repeat with wRep = 1 to 11
  352.         testheight = wRep * 40
  353.         if TargetLoc[2] < testheight then
  354.           addparticle(3, point(bubblepoint[1], testheight) * 10, point(0, 0))
  355.           bubblepoint[2] = bubblepoint[2] + 30
  356.         end if
  357.       end repeat
  358.       set the loc of sprite (playerSO + 1) to point(-50, -50)
  359.     else
  360.       if playerLocData[4] > 0 then
  361.         playerLocData[5] = 200 - ((floorHeight - playerLocData[4]) * 200 / floorHeight)
  362.         playerLocData[5] = 200
  363.         playerLocData[6] = 0
  364.         addRescueThing(point(playerLocData[2], floorHeight - 15), point(playerLocData[2], floorHeight - playerLocData[4]))
  365.         set the loc of sprite (playerSO + 1) to point(-50, -50)
  366.         playerLocData[4] = 0
  367.       else
  368.         if playerLocData[5] > 50 then
  369.           playerLocData[6] = playerLocData[6] - 4
  370.         else
  371.           playerLocData[6] = playerLocData[6] + 4
  372.         end if
  373.         playerLocData[5] = playerLocData[5] + playerLocData[6]
  374.         if playerLocData[5] <= 0 then
  375.           playerLocData[5] = 0
  376.           playerLocData[6] = abs(integer(playerLocData[6] / 2))
  377.         end if
  378.       end if
  379.     end if
  380.   end if
  381.   set the loc of sprite (playerSO + 2) to point(playerLocData[2], floorHeight - 25)
  382.   playerLocData[5] = playerLocData[5] * 0.75
  383.   if playerLocData[5] > 200 then
  384.     playerLocData[5] = 200
  385.   end if
  386.   playerLocData[2] = playerLocData[2] + playerLocData[3]
  387.   if playerLocData[2] > (580 - 30) then
  388.     playerLocData[2] = 580 - 30
  389.   end if
  390.   if playerLocData[2] < 30 then
  391.     playerLocData[2] = 30
  392.   end if
  393.   set the member of sprite playerSO to "Bow " & string(integer((playerLocData[5] / 10) + 1))
  394.   set the ink of sprite playerSO to 36
  395.   set the loc of sprite playerSO to point(playerLocData[2], floorHeight - 25)
  396.   if rescueData[1][1] = 1 then
  397.     set the loc of sprite (playerSO + 2) to point(-50, -50)
  398.   else
  399.     set the loc of sprite (playerSO + 2) to point(playerLocData[2], floorHeight - 60 + (playerLocData[5] / 5))
  400.   end if
  401. end
  402.